home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / MOR55SRC.ZIP / MORIA / SOURCE / POTIONS.C < prev    next >
C/C++ Source or Header  |  1992-12-07  |  9KB  |  393 lines

  1. /* source/potions.c: code for potions
  2.  
  3.    Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  4.  
  5.    This software may be copied and distributed for educational, research, and
  6.    not for profit purposes provided that this copyright and statement are
  7.    included in all such copies. */
  8.  
  9. #include "config.h"
  10. #include "constant.h"
  11. #include "types.h"
  12. #include "externs.h"
  13.  
  14. #ifdef USG
  15. #include <string.h>
  16. #else
  17. #include <strings.h>
  18. #endif
  19.  
  20. /* Potions for the quaffing                -RAK-    */
  21. void quaff()
  22. {
  23.   int32u i, l;
  24.   int j, k, item_val;
  25.   int ident;
  26.   register inven_type *i_ptr;
  27.   register struct misc *m_ptr;
  28.   register struct flags *f_ptr;
  29. #if 0
  30.   /* used by ifdefed out learn_spell potion */
  31.   register class_type *c_ptr;
  32. #endif
  33.  
  34.   free_turn_flag = TRUE;
  35.   if (inven_ctr == 0)
  36.     msg_print("But you are not carrying anything.");
  37.   else if (!find_range(TV_POTION1, TV_POTION2, &j, &k))
  38.     msg_print("You are not carrying any potions.");
  39.   else if (get_item(&item_val, "Quaff which potion?", j, k, CNIL, CNIL))
  40.     {
  41.       i_ptr = &inventory[item_val];
  42.       i = i_ptr->flags;
  43.       free_turn_flag = FALSE;
  44.       ident = FALSE;
  45.       if (i == 0)
  46.     {
  47.       msg_print ("You feel less thirsty.");
  48.       ident = TRUE;
  49.     }
  50.       else while (i != 0)
  51.     {
  52.       j = bit_pos(&i) + 1;
  53.       if (i_ptr->tval == TV_POTION2)
  54.         j += 32;
  55.       /* Potions                        */
  56.       switch(j)
  57.         {
  58.         case 1:
  59.           if (inc_stat (A_STR))
  60.         {
  61.           msg_print("Wow!  What bulging muscles!");
  62.           ident = TRUE;
  63.         }
  64.           break;
  65.         case 2:
  66.           ident = TRUE;
  67.           lose_str();
  68.           break;
  69.         case 3:
  70.           if (res_stat (A_STR))
  71.         {
  72.           msg_print("You feel warm all over.");
  73.           ident = TRUE;
  74.         }
  75.           break;
  76.         case 4:
  77.           if (inc_stat (A_INT))
  78.         {
  79.           msg_print("Aren't you brilliant!");
  80.           ident = TRUE;
  81.         }
  82.           break;
  83.         case 5:
  84.           ident = TRUE;
  85.           lose_int();
  86.           break;
  87.         case 6:
  88.           if (res_stat (A_INT))
  89.         {
  90.           msg_print("You have have a warm feeling.");
  91.           ident = TRUE;
  92.         }
  93.           break;
  94.         case 7:
  95.           if (inc_stat (A_WIS))
  96.         {
  97.           msg_print("You suddenly have a profound thought!");
  98.           ident = TRUE;
  99.         }
  100.           break;
  101.         case 8:
  102.           ident = TRUE;
  103.           lose_wis();
  104.           break;
  105.         case 9:
  106.           if (res_stat (A_WIS))
  107.         {
  108.           msg_print("You feel your wisdom returning.");
  109.           ident = TRUE;
  110.         }
  111.           break;
  112.         case 10:
  113.           if (inc_stat (A_CHR))
  114.         {
  115.           msg_print("Gee, ain't you cute!");
  116.           ident = TRUE;
  117.         }
  118.           break;
  119.         case 11:
  120.           ident = TRUE;
  121.           lose_chr();
  122.           break;
  123.         case 12:
  124.           if (res_stat (A_CHR))
  125.         {
  126.           msg_print("You feel your looks returning.");
  127.           ident = TRUE;
  128.         }
  129.           break;
  130.         case 13:
  131.           ident = hp_player(damroll(2, 7));
  132.           break;
  133.         case 14:
  134.           ident = hp_player(damroll(4, 7));
  135.           break;
  136.         case 15:
  137.           ident = hp_player(damroll(6, 7));
  138.           break;
  139.         case 16:
  140.           ident = hp_player(1000);
  141.           break;
  142.         case 17:
  143.           if (inc_stat (A_CON))
  144.         {
  145.           msg_print("You feel tingly for a moment.");
  146.           ident = TRUE;
  147.         }
  148.           break;
  149.         case 18:
  150.           m_ptr = &py.misc;
  151.           if (m_ptr->exp < MAX_EXP)
  152.         {
  153.           l = (m_ptr->exp / 2) + 10;
  154.           if (l > 100000L)  l = 100000L;
  155.           m_ptr->exp += l;
  156.           msg_print("You feel more experienced.");
  157.           prt_experience();
  158.           ident = TRUE;
  159.         }
  160.           break;
  161.         case 19:
  162.           f_ptr = &py.flags;
  163.           if (!f_ptr->free_act)
  164.         {
  165.           /* paralysis must == 0, otherwise could not drink potion */
  166.           msg_print("You fall asleep.");
  167.           f_ptr->paralysis += randint(4) + 4;
  168.           ident = TRUE;
  169.         }
  170.           break;
  171.         case 20:
  172.           f_ptr = &py.flags;
  173.           if (f_ptr->blind == 0)
  174.         {
  175.           msg_print("You are covered by a veil of darkness.");
  176.           ident = TRUE;
  177.         }
  178.           f_ptr->blind += randint(100) + 100;
  179.           break;
  180.         case 21:
  181.           f_ptr = &py.flags;
  182.           if (f_ptr->confused == 0)
  183.         {
  184.           msg_print("Hey!  This is good stuff!  * Hick! *");
  185.           ident = TRUE;
  186.         }
  187.           f_ptr->confused += randint(20) + 12;
  188.           break;
  189.         case 22:
  190.           f_ptr = &py.flags;
  191.           if (f_ptr->poisoned == 0)
  192.         {
  193.           msg_print("You feel very sick.");
  194.           ident = TRUE;
  195.         }
  196.           f_ptr->poisoned += randint(15) + 10;
  197.           break;
  198.         case 23:
  199.           if (py.flags.fast == 0)
  200.         ident = TRUE;
  201.           py.flags.fast += randint(25) + 15;
  202.           break;
  203.         case 24:
  204.           if (py.flags.slow == 0)
  205.         ident = TRUE;
  206.           py.flags.slow += randint(25) + 15;
  207.           break;
  208.         case 26:
  209.           if (inc_stat (A_DEX))
  210.         {
  211.           msg_print("You feel more limber!");
  212.           ident = TRUE;
  213.         }
  214.           break;
  215.         case 27:
  216.           if (res_stat (A_DEX))
  217.         {
  218.           msg_print("You feel less clumsy.");
  219.           ident = TRUE;
  220.         }
  221.           break;
  222.         case 28:
  223.           if (res_stat (A_CON))
  224.         {
  225.           msg_print("You feel your health returning!");
  226.           ident = TRUE;
  227.         }
  228.           break;
  229.         case 29:
  230.           ident = cure_blindness();
  231.           break;
  232.         case 30:
  233.           ident = cure_confusion();
  234.           break;
  235.         case 31:
  236.           ident = cure_poison();
  237.           break;
  238. #if 0
  239.         case 33:
  240.           /* this is no longer useful, now that there is a 'G'ain magic
  241.          spells command */
  242.           m_ptr = &py.misc;
  243.           c_ptr = &class[m_ptr->pclass];
  244.           if (c_ptr->spell == MAGE)
  245.         {
  246.           calc_spells(A_INT);
  247.           calc_mana(A_INT);
  248.         }
  249.           else if (c_ptr->spell == PRIEST)
  250.         {
  251.           calc_spells(A_WIS);
  252.           calc_mana(A_WIS);
  253.         }
  254.           else
  255.         {
  256.           /* A warrior learns something about his equipment. -CJS- */
  257.           inven_type *w_ptr;
  258.           vtype tmp_str;
  259.           extern char *describe_use ();
  260.  
  261.           for (k = 22; k < INVEN_ARRAY_SIZE; k++)
  262.             {
  263.               w_ptr = &inventory[k];
  264.               if (w_ptr->tval != TV_NOTHING && enchanted (w_ptr))
  265.             {
  266.               (void) sprintf (tmp_str,
  267.                   "There's something about what you are %s...",
  268.                       describe_use(k));
  269.               msg_print (tmp_str);
  270.               add_inscribe(w_ptr, ID_MAGIK);
  271.               ident = TRUE;
  272.             }
  273.             }
  274.         }
  275.           break;
  276. #endif
  277.         case 34:
  278.           if (py.misc.exp > 0)
  279.         {
  280.           int32 m, scale;
  281.           msg_print("You feel your memories fade.");
  282.           /* Lose between 1/5 and 2/5 of your experience */
  283.           m = py.misc.exp / 5;
  284.           if (py.misc.exp > MAX_SHORT)
  285.             {
  286.               scale = MAX_LONG / py.misc.exp;
  287.               m += (randint((int)scale) * py.misc.exp) / (scale * 5);
  288.             }
  289.           else
  290.             m += randint((int)py.misc.exp) / 5;
  291.           lose_exp(m);
  292.           ident = TRUE;
  293.         }
  294.           break;
  295.         case 35:
  296.           f_ptr = &py.flags;
  297.           (void) cure_poison();
  298.           if (f_ptr->food > 150)  f_ptr->food = 150;
  299.           f_ptr->paralysis = 4;
  300.           msg_print("The potion makes you vomit!");
  301.           ident = TRUE;
  302.           break;
  303.         case 36:
  304.           if (py.flags.invuln == 0)
  305.         ident = TRUE;
  306.           py.flags.invuln += randint(10) + 10;
  307.           break;
  308.         case 37:
  309.           if (py.flags.hero == 0)
  310.         ident = TRUE;
  311.           py.flags.hero += randint(25) + 25;
  312.           break;
  313.         case 38:
  314.           if (py.flags.shero == 0)
  315.         ident = TRUE;
  316.           py.flags.shero += randint(25) + 25;
  317.           break;
  318.         case 39:
  319.           ident = remove_fear();
  320.           break;
  321.         case 40:
  322.           ident = restore_level();
  323.           break;
  324.         case 41:
  325.           f_ptr = &py.flags;
  326.           if (f_ptr->resist_heat == 0)
  327.         ident = TRUE;
  328.           f_ptr->resist_heat += randint(10) + 10;
  329.           break;
  330.         case 42:
  331.           f_ptr = &py.flags;
  332.           if (f_ptr->resist_cold == 0)
  333.         ident = TRUE;
  334.           f_ptr->resist_cold += randint(10) + 10;
  335.           break;
  336.         case 43:
  337.           if (py.flags.detect_inv == 0)
  338.         ident = TRUE;
  339.           detect_inv2(randint(12)+12);
  340.           break;
  341.         case 44:
  342.           ident = slow_poison();
  343.           break;
  344.         case 45:
  345.           ident = cure_poison();
  346.           break;
  347.         case 46:
  348.           m_ptr = &py.misc;
  349.           if (m_ptr->cmana < m_ptr->mana)
  350.         {
  351.           m_ptr->cmana = m_ptr->mana;
  352.           ident = TRUE;
  353.           msg_print("Your feel your head clear.");
  354.           prt_cmana();
  355.         }
  356.           break;
  357.         case 47:
  358.           f_ptr = &py.flags;
  359.           if (f_ptr->tim_infra == 0)
  360.         {
  361.           msg_print("Your eyes begin to tingle.");
  362.           ident = TRUE;
  363.         }
  364.           f_ptr->tim_infra += 100 + randint(100);
  365.           break;
  366.         default:
  367.           msg_print ("Internal error in potion()");
  368.           break;
  369.         }
  370.       /* End of Potions.                    */
  371.     }
  372.       if (ident)
  373.     {
  374.       if (!known1_p(i_ptr))
  375.         {
  376.           m_ptr = &py.misc;
  377.           /* round half-way case up */
  378.           m_ptr->exp += (i_ptr->level + (m_ptr->lev >> 1)) / m_ptr->lev;
  379.           prt_experience();
  380.  
  381.           identify(&item_val);
  382.           i_ptr = &inventory[item_val];
  383.         }
  384.     }
  385.       else if (!known1_p(i_ptr))
  386.     sample (i_ptr);
  387.  
  388.       add_food(i_ptr->p1);
  389.       desc_remain(item_val);
  390.       inven_destroy(item_val);
  391.     }
  392. }
  393.